package com.hzhjhh.view.manageView.menus.storage.inOutStorage;

import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

import com.hzhjhh.init.dialog.Mytable;
import com.hzhjhh.view.manageView.menus.storage.InOutTableDialog;
import com.hzhjhh.view.manageView.menus.storage.constant.ShowConstants;

/**
 * 菜单栏初始化-仓库-进库/出库-确定按钮
 * 
 * @author 12083
 *
 */
public class EnsureBt {

	/**
	 * 按钮
	 */
	public static JButton btInit(InOutTableDialog inOutTableDialog) {
		JButton ensure = new JButton();
		ensure.setBounds(74, 409, 111, 30);
		ensure.setText("确   认");
		ensure.setSelectedIcon(null);
		ensure.addActionListener(event -> {
			JTextField jTextField1 = inOutTableDialog.getTime();
			JTextField jTextField2 = inOutTableDialog.getTfMerchandiseCode();
			JTextField jTextField3 = inOutTableDialog.getJTextField3();
			JTextField jTextField4 = inOutTableDialog.getJTextField4();
			JTextField jTextField6 = inOutTableDialog.getJTextField6();
			JTextField jTextField7 = inOutTableDialog.getJTextField7();
			JComboBox jComboBox2 = inOutTableDialog.getJComboBox2();
			JComboBox jComboBox3 = inOutTableDialog.getJComboBox3();
			Vector vector1 = inOutTableDialog.getVector1();
			JTable jTable1 = inOutTableDialog.getJTable1();
			JScrollPane jScrollPane1 = inOutTableDialog.getJScrollPane1();
			
			Vector vector = new Vector();
			double allMoney = 0;
			vector.add(jTextField2.getText());
			vector.add(jTextField3.getText());
			vector.add(jTextField4.getText());
			try {
				Double num = new Double(jTextField3.getText());
				Double money = new Double(jTextField4.getText());
				allMoney = (int) (num * money * 100) / 100.0;
			} catch (Exception ex) {
				JOptionPane.showMessageDialog(inOutTableDialog, "输入的数字有误", "错误", JOptionPane.ERROR_MESSAGE);
				return;
			}
			Double dd = new Double(allMoney);
			jTextField6.setText(dd.toString());
			vector.add(dd.toString());
			vector.add(jTextField1.getText());
			vector.add(jComboBox3.getSelectedItem().toString());
			vector.add(jTextField7.getText());
			vector.add(jComboBox2.getSelectedItem().toString());
			vector1.add(vector);
			jTable1 = Mytable.maketable(vector1, ShowConstants.IN_OUT_TABLE_HEAD_NAME); // 显示内容
			jScrollPane1.getViewport().add(jTable1); // 把表装入容器
		});
		return ensure;
	}
}
